package com.smrs.basicdata.webapp.action;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.jof.framework.util.Pager;
import com.smrs.basicdata.enums.DictTypeEnum;
import com.smrs.basicdata.enums.StoreTypeEnum;
import com.smrs.basicdata.model.ChannelModel;
import com.smrs.basicdata.model.DictAreaModel;
import com.smrs.basicdata.model.RegionModel;
import com.smrs.basicdata.model.StoreModel;
import com.smrs.basicdata.vo.StoreSearchModel;
import com.smrs.enums.StatusEnum;
import com.smrs.security.model.UserModel;
import com.smrs.util.AppUtil;
import com.smrs.util.DateCommonUtil;

public class StoreJsonAction extends StoreAction{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 109L;
	
	
	protected Long regionId;
	
	public Long getRegionId() {
		return regionId;
	}

	public void setRegionId(Long regionId) {
		this.regionId = regionId;
	}
	
	protected void writeStoreToJson(List<StoreModel> list){
		
		List<KeyValueModel> listTemp = new ArrayList<KeyValueModel>();
    	if(list!=null){
        	for(StoreModel area:list){
        		KeyValueModel model = new KeyValueModel();
        		model.setId(area.getId()+"");
        		model.setName(area.getName());
        		listTemp.add(model);
        	}
         writeOutJson(listTemp);
    	}

	}
	public String queryStoreJson(){
		//Integer iStoreType= store.getStoreType();
		StoreTypeEnum tempStoreType = StoreTypeEnum.toEnum(storeType);
		StoreSearchModel searchModel=new StoreSearchModel();
		searchModel.setPager(pager);
		Pager<StoreModel> tempPager = storeService.getByNameLikeAndTypePager(searchModel, tempStoreType);
		List<StoreModel> list = tempPager.getRecords();
		writeStoreToJson(list);
		return null;
	}
	
	public String queryStoreByRegionJson(){		
		List<StoreModel> list = storeService.findByRegionId(regionId);
		writeStoreToJson(list);
		return null;
	}

}
